<?xml version="1.0" encoding="UTF-8" ?>
<%--
/***********************************************
* 파일명 : vacation_allocation.jsp
* 기  능 : 휴가관리 - 휴가 배정
* 최초 작성일 : 2008/01/21
* @author : Yang Chang Hwan
*************************************************/
--%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib 	prefix="s" 		uri="/struts-tags"%>

<%response.addHeader("X-UA-Compatible" , "IE=EmulateIE7"); %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
	<s:head theme="ajax" />
	<script src="/inc/js/aa.js"></script>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta http-equiv="pragma" 			content="no-cache" />
	<meta http-equiv="cache-control" 	content="no-cache" />
	<meta http-equiv="expires" 			content="0" />
	<title>휴가관리-휴가배정</title>
	<!-- --------------------J A V A S C R I P T-START-------------------- -->
	<script type="text/javascript">
	<!--
		//체크한 값을 넘기기 위한 전역변수
		var args;
		
		function fnc_check(field) {
			
			args = new Array();	//배열생성
			
			if (!field) {
				alert("<s:text name="alert.message.notCheck" />");
				return false;
			}

			//체크박스가 하나일 경우 처리하는 로직
			if (!field.length) {
				if (!field.checked) {
					alert("<s:text name="alert.message.requiedCheck"/>");
					field.focus();
					return false;
				} else {
					args.push(field.value);
					return true;
				}
			}
			
			var checkflag = false;	//check init
			
			//체크된것이 없을시에 알람 메시지 출력
			//alert(field.length);	//checkbox 갯수
			for(i = 0 ; i < field.length ; i++) {
				if (!field[i].checked) {
					continue;
				} else {
					checkflag = true;
					//alert(field[i].value)
					args.push(field[i].value);	//배열에 값을 넣는다.
				}
			}
			
			//체크되지 않았으면 메시지 출력
			if (!checkflag) {
				alert("<s:text name="alert.message.selectData" />");
				return false;
			}
	
			return true;
		}
		
		function fnc_selct_items(f) {
			alert(f.value);
		}

		function fnc_allocate(f) {

			// 값이 없으면 팅겨내기
			if (!fnc_check(f)) {
				return false;
			}

			//hidden값에 체크된 emp_no 담기
			document.getElementById("ch_emp_no").value = args;

			var w = 350;
			var h = 400;
     
			var x = fnc_center_x(w);
			var y = fnc_center_y(h);

			var f = document.frm;
  
			var uri 	= 	"vaca_alloc_p.action";
			var nm		=	"p_vacaAlloc";
			var attr    =   "width=" + w + " , height=" + h + " , top=" + y + " , left=" + x + " , scrollbars=no , status=no";       //window size

			uri 		+= 	"?emp_no=" + args;
  	
			window.open("" , nm , attr);
  	
			f.target 	= 	nm;
			f.action	=	uri;
			f.submit();
  	
			return false;
  		}

		
		//배정버튼 클
		//function fnc_allocate(f) {
			
		//	if (!fnc_check(f)) {
		//		return false;
		//	}
			
		//	var url			=	"vaca_alloc_p.action";
		//	window.showModalDialog(url , self, "dialogWidth:350px; dialogHeight:300px; scroll:no; status:no; resizable=no;");
				
		//	return false;
		//}
		
		//조회버튼 클릭시 실행됨.
		function fnc_retrieve() {
			call_dojo();
			return false;
		}
		
		//ajax로 조회리스트 호출.
	    function call_dojo() {
	        dojo.event.topic.publish("ajax_list");
	    }

	  //조회버튼 클릭시 실행됨.
		function fnc_delete(txt) {
			alert(txt);
			call_dojo();
			return false;
		}
	    
	    /**
	    *그룹선택이 변경될 경우에 팀과 사원  list를 변경한다.
	    */
/*	    function selectChange(type) {
	    
	    	if (type == "group") {
				dojo.event.topic.publish("show_team");
		    	
				dojo.event.topic.publish("show_emp");
	    	} else if (type == "team") {
				dojo.event.topic.publish("show_emp");
	    	}
			return false;
		}  */

		function selectChange(type){
			if (type == "group") {
	    		$("#sgroup").css({backgroundColor:'#3366FF', color:'#FFFFFF'});
	    		if($("#sgroup").val()=="ALL"){
	    			$("#sgroup").css({backgroundColor:'#ffffff',color:'#656464'});
		    		}
				dojo.event.topic.publish("show_team");	//팀
				
				dojo.event.topic.publish("show_emp");	//사원
	    	} else if (type == "team") {
	    		$("#steam").css({backgroundColor:'#3366FF', color:'#FFFFFF'});
	    		if($("#steam").val()=="ALL"){
	    			$("#steam").css({backgroundColor:'#ffffff', color:'#656464'});
		    		}
	    			dojo.event.topic.publish("show_emp");	//사원
	    	}else if (type == "emp")  {
	    		$("#semp_no").css({backgroundColor:'#3366FF',color:'#FFFFFF'});
	    		if($("#semp_no").val() == "ALL"){
                    $("#semp_no").css({backgroundColor:'#ffffff',color:'#656464'});
		    		}
					//dojo.event.topic.publish("show_emp");	//사원
                          
		    }
	    	return false;
		}

		//전체선택
		function selectCheck() {
			
			var check 		= frm.s_chk;
			
			var selectAll 	= frm.selectAll.checked;
			
			if( selectAll ) {
				check.checked = true;
				
				for(i=0 ; i < check.length ; i++){
				   check[i].checked=true;
				}
			} else {
				check.checked = false;
				
				for(i=0 ; i < check.length ; i++){
				   check[i].checked=false;
				}
			}		
		}

	    function fnc_assign_pop(emp_no, assign_type) {

			var w = 595;
			var h = 450;
	       
			var x = fnc_center_x(w);
			var y = fnc_center_y(h);
	    
			var f		=	document.frm;
	    	
			var uri 	= 	"vacaAssign_mod_p.action";
			var nm		=	"p_assign";
			var attr    =   "width=" + w + " , height=" + h + " , top=" + y + " , left=" + x + " , scrollbars=yes , status=no";       //window size
	    	
			if (emp_no.replace(/^\s\s*/, '').replace(/\s\s*$/, '').length != 0) {
				uri			+=	"?" + "tmp_emp_no=" + emp_no;
			}

			if (assign_type.replace(/^\s\s*/, '').replace(/\s\s*$/, '').length != 0) {
				uri			+=	"&" + "assign_type=" + assign_type;
			}
	    		
			window.open("" , nm , attr);
	    	
			f.target 	= 	nm;
			f.action	=	uri;
	    	
			f.submit();
	    	
			return false;
		}

		/*********************************************CALENDER******************************************************/
		/////////////////////달력////////////////////////////////////////////////
			function doOnLoad()
			{
				// 달력
				cal1 = new dhtmlxCalendarObject('standard_date', false, {isYearEditable: true});
				cal1.setYearsRange(2000, 2050);
				cal1.setPosition(20,-82);
				cal1.draw();
				cal1.setOnClickHandler(selectDate1);
		
				cal2 = new dhtmlxCalendarObject('standard_date', false, {isYearEditable: true});
				cal2.setYearsRange(2000, 2050);
				cal2.setPosition(20,-82);
				cal2.draw();
				// cal2.setOnClickHandler(selectDate2);
		
				document.getElementById('standard_date').onfocus = function() { if (cal2.isVisible()) cal2.hide(); }
		
				document.body.onclick = function(){calendarHide("cal1,cal2","D");};
			}
		
			function selectDate1(date)
			{
				document.getElementById('standard_date').value = cal1.getFormatedDate(null,date);
				dateFrom = new Date(date);
				dateTo = null;
				cal2.setSensitive(dateFrom, dateTo);
				cal1.hide();
				return true;
			}
		
		/////////////////////달력////////////////////////////////////////////////
		/*********************************************CALENDER******************************************************/

	//-->
	</script>
	</head>
<body onload="doOnLoad();">
	<div class="fl_ri">
		<div id="contants_box">
			<div id="tit">  
				<span class="fl_ri tit_navi">Home &gt; 관리자 &gt; <span class="f_b">휴가관리</span><img src="/images/btl_navi.gif" class="img_tp" /></span>
				<div class="fl_le"><img src="/images/tit_menu05_img01.gif" /></div>
			</div>
		<s:form theme="simple"  name="frm" id="frm">
			
			<!-- 데이터 체크 결과 및 업데이트 결과를 담고 있는 변수 -->
			<s:hidden id="cur_page" name="cur_page"/>
			<s:hidden id="ch_emp_no" name="ch_emp_no"/>
			<!----------Search_Box : STR ---------->
			<div id="search01">
			<div id="search_box02">
				<ul>
					<li class="txt">휴가기준일</li>
					<li class="input">
						<input type="text" size="12" maxlength="10" name="standard_date" id="standard_date" value="<s:property value="standard_date" />" class="input_100se" style="height:20;background-image:url('images/calendar/calendar.gif');background-repeat:no-repeat;background-position:right 2px;cursor:hand" />
					</li>
				</ul>
				<ul>
					<li class="txt">그룹</li>
					<li class="input">
						<s:select id="sgroup" 	name="sgroup" list="listGroup" cssClass="combobox140se" headerKey="ALL" headerValue="::전체::"	listKey="group_no" listValue="group_nm" onchange="return selectChange('group')" />
					</li>
					<li class="txt01">팀</li>
					<li class="input">
						<s:url id="team_url" action="com_select_team_s" />
							<s:div showLoadingText="false" id="team_div" href="%{team_url}" theme="ajax" listenTopics="show_team" formId="frm"/>
					</li>
					<li class="txt01 ">성명</li>
					<li class="input">
						<s:url id="emp_url" action="com_select_emp_s" />
							<s:div showLoadingText="false" id="emp_div" href="%{emp_url}" theme="ajax" listenTopics="show_emp" formId="frm"/>
					</li>
					<li class="txt01">성명 조회</li>
					<li class="input">
						<input type="text" name="empNm" id="empNm" class="input_75se" maxlength="5" />
					</li>
				</ul>
				
				<ul class="cebtn">
					<span class="fl_ri">
						<s:submit type='image' src="/images/btn_search.gif" cssClass="img_area" title="조회"  onclick="return getList('search')" />
						<s:submit type='image' src="/images/btn_app.gif" cssClass="img_area" title="휴가배정" value="배정" onclick="return fnc_allocate(this.form.s_chk)" />
					</span>
				</ul>
			
			</div>
			</div>	
			<!----------Search_Box : ENd ---------->  
		<!-- ajax로 데이터를 조회해 온다. -->
		<center>
		<s:url id="ajax_list"  action="ajax_alloc_vacation_list" />
		<s:div id="itemAmtlistDiv" theme="ajax" executeScripts="true" showLoadingText="true" loadingText='<img src="./images/loading_request.gif" />' href="%{ajax_list}" listenTopics="ajax_list" formId="frm" />
		</center>	
		</s:form>
		</div>
	</div>
</body>
</html>